#if !defined(__CLIENT_PROFILE_MANAGER_H)
#define __CLIENT_PROFILE_MANAGER_H

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "Util.h"
//#include <map>

#include "CriticalSection.h"
#include "Singleton.h"
//Sulan start svn93
#include "ResourceManager.h"
//End

// pothead starts svn196 (sulan code)
class MyinfoProfile {
	public:
	typedef vector<MyinfoProfile> List;
	typedef List::iterator Iter;

	MyinfoProfile() : id(0), priority(0), rawToSend(0) { };

	MyinfoProfile(int aId, const string& aName, const string& aVersion, const string& aTag, 
		const string& aExtendedTag, const string& aNick, const string& aShared, const string& aEmail, 
		const string& aStatus, const string& aCheatingDescription, int aRawToSend, bool aUseExtraVersion,
		const string& aConnection, const string& aComment) throw() : 
		id(aId), name(aName), version(aVersion), tag(aTag), extendedTag(aExtendedTag), nick(aNick), shared(aShared), 
		email(aEmail), status(aStatus), cheatingDescription(aCheatingDescription), rawToSend(aRawToSend),	
		useExtraVersion(aUseExtraVersion), connection(aConnection), comment(aComment) { };

	MyinfoProfile(const MyinfoProfile& rhs) : id(rhs.id), name(rhs.name), version(rhs.version), tag(rhs.tag), 
		extendedTag(rhs.extendedTag), nick(rhs.nick), shared(rhs.shared), email(rhs.email), 
		status(rhs.status), cheatingDescription(rhs.cheatingDescription), rawToSend(rhs.rawToSend), 
		useExtraVersion(rhs.useExtraVersion), connection(rhs.connection), comment(rhs.comment) { }

	MyinfoProfile& operator=(const MyinfoProfile& rhs) {
		id = rhs.id;
		name = rhs.name;
		version = rhs.version;
		tag = rhs.tag;
		extendedTag = rhs.extendedTag;
		nick = rhs.nick;
		shared = rhs.shared;
		email = rhs.email;
		status = rhs.status;
		rawToSend = rhs.rawToSend;
		cheatingDescription = rhs.cheatingDescription;
		useExtraVersion = rhs.useExtraVersion;
		connection = rhs.connection;
		comment = rhs.comment;
		return *this;
	}

	GETSET(int, id, Id);
	GETSET(string, name, Name);
	GETSET(string, version, Version);
	GETSET(string, tag, Tag);
	GETSET(string, extendedTag, ExtendedTag);
	GETSET(string, nick, Nick);
	GETSET(string, shared, Shared);
	GETSET(string, email, Email);
	GETSET(string, status, Status);
	GETSET(string, cheatingDescription, CheatingDescription);
	GETSET(string, connection, Connection);
	GETSET(string, comment, Comment);
	GETSET(int, priority, Priority);
	GETSET(int, rawToSend, RawToSend);
	GETSET(bool, useExtraVersion, UseExtraVersion);

};
// pothead ends
// pothead starts svn207
class RawProfile {
	public:
	typedef vector<RawProfile> List;
	typedef List::iterator Iter;

	RawProfile() : id(0) { };

	RawProfile(int aId, const string& aName, const string& aRaw1, const string& aRaw2, const string& aRaw3, 
		const string& aRaw4, const string& aRaw5, const string& aRaw6, const string& aRaw7, const string& aRaw8, 
		const string& aRaw9, const string& aRaw10) throw() : 
		id(aId), name(aName), raw1(aRaw1), raw2(aRaw2), raw3(aRaw3), raw4(aRaw4), raw5(aRaw5), raw6(aRaw6), 
		raw7(aRaw7), raw8(aRaw8), raw9(aRaw9), raw10(aRaw10) { };

	RawProfile(const RawProfile& rhs) : id(rhs.id), name(rhs.name), raw1(rhs.raw1), raw2(rhs.raw2), raw3(rhs.raw3),
		raw4(rhs.raw4), raw5(rhs.raw5), raw6(rhs.raw6), raw7(rhs.raw7), raw8(rhs.raw8), raw9(rhs.raw9), 
		raw10(rhs.raw10) { }

	RawProfile& operator=(const RawProfile& rhs) {
		id = rhs.id;
		name = rhs.name;
		raw1 = rhs.raw1;
		raw2 = rhs.raw2;
		raw3 = rhs.raw3;
		raw4 = rhs.raw4;
		raw5 = rhs.raw5;
		raw6 = rhs.raw6;
		raw7 = rhs.raw7;
		raw8 = rhs.raw8;
		raw9 = rhs.raw9;
		raw10 = rhs.raw10;
		return *this;
	}

		GETSET(int, id, Id);
		GETSET(string, name, Name);
		GETSET(string, raw1, Raw1);
		GETSET(string, raw2, Raw2);
		GETSET(string, raw3, Raw3);
		GETSET(string, raw4, Raw4);
		GETSET(string, raw5, Raw5);
		GETSET(string, raw6, Raw6);
		GETSET(string, raw7, Raw7);
		GETSET(string, raw8, Raw8);
		GETSET(string, raw9, Raw9);
		GETSET(string, raw10, Raw10);
};
// pothead ends

class ClientProfile {
	public:
	typedef vector<ClientProfile> List;
	typedef List::iterator Iter;

	ClientProfile() : id(0), priority(0), rawToSend(0) { };

	ClientProfile(int aId, const string& aName, const string& aVersion, const string& aTag,
		const string& aExtendedTag, const string& aLock, const string& aPk, const string& aSupports,
		const string& aTestSUR, const string& aUserConCom, const string& aStatus, const string& aCheatingDescription, 
		int aRawToSend, /*int aTagVersion,*/ bool aUseExtraVersion, bool aCheckMismatch,
		const string& aConnection, const string& aComment, bool aRecheck, bool aSkipExtended, bool aSkipExtended2
		) 
		throw() : id(aId), name(aName), version(aVersion), tag(aTag), extendedTag(aExtendedTag), lock(aLock), pk(aPk),
		supports(aSupports), testSUR(aTestSUR), userConCom(aUserConCom), status(aStatus), 
		cheatingDescription(aCheatingDescription), rawToSend(aRawToSend), useExtraVersion(aUseExtraVersion), 
		checkMismatch(aCheckMismatch), connection(aConnection), comment(aComment), recheck(aRecheck), 
		skipExtended(aSkipExtended), skipExtended2(aSkipExtended2) { };

	ClientProfile(const ClientProfile& rhs) : id(rhs.id), name(rhs.name), version(rhs.version), tag(rhs.tag), 
		extendedTag(rhs.extendedTag), lock(rhs.lock), pk(rhs.pk), supports(rhs.supports), testSUR(rhs.testSUR), 
		userConCom(rhs.userConCom), status(rhs.status), cheatingDescription(rhs.cheatingDescription), 
		rawToSend(rhs.rawToSend), /*tagVersion(rhs.tagVersion),*/ useExtraVersion(rhs.useExtraVersion), 
		checkMismatch(rhs.checkMismatch), connection(rhs.connection), comment(rhs.comment), recheck(rhs.recheck), 
		skipExtended(rhs.skipExtended), skipExtended2(rhs.skipExtended2) { }

	ClientProfile& operator=(const ClientProfile& rhs) { 
		id = rhs.id;
		name = rhs.name;
		version = rhs.version;
		tag = rhs.tag;
		extendedTag = rhs.extendedTag;
		lock = rhs.lock;
		pk = rhs.pk;
		supports = rhs.supports;
		testSUR = rhs.testSUR;
		userConCom = rhs.userConCom;
		status = rhs.status;
		rawToSend = rhs.rawToSend;
		cheatingDescription = rhs.cheatingDescription;
		//tagVersion = rhs.tagVersion;
		useExtraVersion = rhs.useExtraVersion;
		checkMismatch = rhs.checkMismatch;
		connection = rhs.connection;
		comment = rhs.comment;
		recheck = rhs.recheck;
		skipExtended = rhs.skipExtended;
		skipExtended2 = rhs.skipExtended2;
		return *this;
	}

	GETSET(int, id, Id);
	GETSET(string, name, Name);
	GETSET(string, version, Version);
	GETSET(string, tag, Tag);
	GETSET(string, extendedTag, ExtendedTag);
	GETSET(string, lock, Lock);
	GETSET(string, pk, Pk);
	GETSET(string, supports, Supports);
	GETSET(string, testSUR, TestSUR);
	GETSET(string, userConCom, UserConCom);
	GETSET(string, status, Status);
	GETSET(string, cheatingDescription, CheatingDescription);
	GETSET(string, connection, Connection);
	GETSET(string, comment, Comment);
	GETSET(int, priority, Priority);
	GETSET(int, rawToSend, RawToSend);
	GETSET(bool, useExtraVersion, UseExtraVersion);
	GETSET(bool, checkMismatch, CheckMismatch);
	GETSET(bool, recheck, Recheck);
	GETSET(bool, skipExtended, SkipExtended);
	GETSET(bool, skipExtended2, SkipExtended2);

	struct setNewRaw {
		setNewRaw(int aRaw) : raw(aRaw) { };
		void operator()(ClientProfile* cp);
		const int& raw;
	};

};

class FakeShares {
public:
	typedef vector<FakeShares> List;
	typedef List::iterator Iter;

	FakeShares() { };
	FakeShares(const string& aValue, const string& aType) throw() : value(aValue), type(aType) { };

	GETSET(string, value, Value);
	GETSET(string, type, Type);
};

class Param {
public:
	Param() { };
	Param(const string& aName, const string& aRegExp) throw() : name(aName), regExp(aRegExp) { };

	GETSET(string, name, Name);
	GETSET(string, regExp, RegExp);
};

class Isp {
public:
	typedef Isp* Ptr;
	typedef map<u_int32_t, Ptr> List;
	typedef List::iterator Iter;

	Isp() { };
	Isp(const string aISP, u_int32_t aLower, bool aBad) : isp(aISP), lower(aLower), bad(aBad) { };

	GETSET(string, isp, Isp);
	GETSET(u_int32_t, lower, Lower);
	GETSET(bool, bad, Bad);
};

class FileListDetectorProfile {
	public:
	typedef vector<FileListDetectorProfile> List;
	typedef List::iterator Iter;

	FileListDetectorProfile() : id(0), rawToSend(0) { };

	FileListDetectorProfile(int aId, const string& aName,
		const string& aCheatingDescription, 	
		int aRawToSend 
		//Sulan start svn120
		, const string& aClient
		//End
		) 
		throw() : id(aId), name(aName), 
		cheatingDescription(aCheatingDescription), rawToSend(aRawToSend)
		//Sulan start svn120
		, client(aClient)
		//End
	{
	
	};

	FileListDetectorProfile(const FileListDetectorProfile& rhs) : id(rhs.id), name(rhs.name),
		//Sulan start svn120
		cheatingDescription(rhs.cheatingDescription), rawToSend(rhs.rawToSend), client(rhs.client){ }
		//End

	FileListDetectorProfile& operator=(const FileListDetectorProfile& rhs) { 
		id = rhs.id;
		name = rhs.name;
		rawToSend = rhs.rawToSend;
		cheatingDescription = rhs.cheatingDescription;
		//Sulan start svn120
		client = rhs.client;
		//End
		return *this;
	}

		GETSET(int, id, Id);
		GETSET(string, name, Name);
		GETSET(string, cheatingDescription, CheatingDescription);
		GETSET(int, rawToSend, RawToSend);
		//Sulan start svn120
		GETSET(string, client, Client);
		//End
};

class SimpleXML;

class ClientProfileManager : public Singleton<ClientProfileManager>
{
public:
	StringMap& getParams() {
		Lock l(ccs);
		return params;
	}	
	FakeShares::List& getFakeShares() {
		Lock l(fcs);
		return fakeShares;
	}
	ClientProfile::List& getClientProfiles() {
		Lock l(ccs);
		return clientProfiles;
	}

	ClientProfile::List& getClientProfiles(StringMap &paramList) {
		Lock l(ccs);
		paramList = params;
		return clientProfiles;
	}
	
	ClientProfile addClientProfile(
		const string& name, 
		const string& version, 
		const string& tag, 
		const string& extendedTag, 
		const string& lock, 
		const string& pk, 
		const string& supports, 
		const string& testSUR, 
		const string& userConCom, 
		const string& status,
		const string& cheatingdescription, 
		int rawToSend, 
		bool useExtraVersion, 
		bool checkMismatch,
		const string& connection,
		const string& comment,
		bool recheck,
		bool skipExtended,
		bool skipExtended2
		) 
	{
		Lock l(ccs);
		clientProfiles.push_back(
			ClientProfile(
			lastProfile++, 
			name, 
			version, 
			tag, 
			extendedTag, 
			lock, 
			pk, 
			supports, 
			testSUR, 
			userConCom, 
			status, 
			cheatingdescription,
			rawToSend, 
			useExtraVersion, 
			checkMismatch,
			connection,
			comment,
			recheck,
			skipExtended,
			skipExtended2	
			)
		);
		return clientProfiles.back();
	}

	//Sulan start svn93
	string addClientProfile( const StringList& sl ) {
		Lock l(ccs);
		clientProfiles.push_back(
			ClientProfile(
			lastProfile++, 
			sl[0], 
			sl[1], 
			sl[2], 
			sl[3], 
			sl[4], 
			sl[5], 
			sl[6], 
			sl[7], 
			sl[8], 
			sl[9], 
			sl[11], 
			0,
			Util::toBool(sl[13]), 
			Util::toBool(sl[14]),
			sl[10],
			sl[12],
			Util::toBool(sl[15]), 
			Util::toBool(sl[16]),
			Util::toBool(sl[17])
			)
		//End
		);
		return STRING(ADDING_CLIENT) +": " + sl[0];
	}

	bool getClientProfile(int id, ClientProfile& cp) {
		Lock l(ccs);
		for(ClientProfile::Iter i = clientProfiles.begin(); i != clientProfiles.end(); ++i) {
			if(i->getId() == id) {
				cp = *i;
				return true;
			}
		}
		return false;
	}

	void removeClientProfile(int id) {
		Lock l(ccs);
		for(ClientProfile::Iter i = clientProfiles.begin(); i != clientProfiles.end(); ++i) {
			if(i->getId() == id) {
				clientProfiles.erase(i);
				break;
			}
		}
	}

	void updateClientProfile(const ClientProfile& cp) {
		Lock l(ccs);
		for(ClientProfile::Iter i = clientProfiles.begin(); i != clientProfiles.end(); ++i) {
			if(i->getId() == cp.getId()) {
				*i = cp;
				break;
			}
		}
	}

	bool moveClientProfile(int id, int pos/*, int position*/) {
		dcassert(pos == -1 || pos == 1);
		Lock l(ccs);
		for(ClientProfile::Iter i = clientProfiles.begin(); i != clientProfiles.end(); ++i) {
			if(i->getId() == id) {
				swap(*i, *(i + pos));
				return true;
			}
		}
		return false;
	}

	ClientProfile::List& reloadClientProfiles() { 
		lastFDProfile = 0;
		lastProfile = 0;
		Lock l(ccs);
		clientProfiles.clear();
		params.clear();
		fileListDetector.clear();
		loadClientProfiles();
		return clientProfiles;
	}


	void reloadClientProfilesFromHttp() { 
		ClientProfile::List oldProfiles = clientProfiles;
		reloadClientProfiles();
		Lock l(ccs);
		//todo: some advanced edit check
		for(ClientProfile::Iter j = clientProfiles.begin(); j != clientProfiles.end(); ++j) {
			for(ClientProfile::Iter k = oldProfiles.begin(); k != oldProfiles.end(); ++k) {
				if((*k).getName().compare((*j).getName()) == 0) {
					(*j).setRawToSend((*k).getRawToSend());
					(*j).setCheatingDescription((*k).getCheatingDescription());
				}
			}
		}
	}


	MyinfoProfile::List& reloadMyinfoProfiles() { 
		lastMyinfoProfile = 0;
		Lock l(ipcs);
		myinfoProfiles.clear();
		loadMyinfoProfiles();
		return myinfoProfiles;
	}
	void reloadMyinfoProfilesFromHttp() {
		MyinfoProfile::List oldProfiles = myinfoProfiles;
		reloadMyinfoProfiles();
		Lock l(ipcs);
		//todo: some advanced edit check
		for(MyinfoProfile::Iter j = myinfoProfiles.begin(); j != myinfoProfiles.end(); ++j) {
			for(MyinfoProfile::Iter k = oldProfiles.begin(); k != oldProfiles.end(); ++k) {
				if((*k).getName().compare((*j).getName()) == 0) {
					(*j).setRawToSend((*k).getRawToSend());
					(*j).setCheatingDescription((*k).getCheatingDescription());
				}
			}
		}
	}


	void reloadISPs() {
		clearISPList();
		loadISPs();
	}

	void load() {
		loadClientProfiles();
		loadFakeShares();
		loadISPs();
		loadMyinfoProfiles();
		loadRawProfiles();
	};
	void insertISP(const u_int32_t high, const u_int32_t low, const string& isp, const bool bad) {
		Lock l(ics);
		ispList.insert(make_pair(high, new Isp(isp, low, bad)));
	}
	void removeISP(const u_int32_t aKey) {
		Lock l(ics);
		Isp::Iter j = ispList.find(aKey);
		if(j != ispList.end()) {
			delete j->second;
			ispList.erase(aKey);
		}
	}
	void clearISPList() {
		Lock l(ics);
		for(Isp::Iter j = ispList.begin(); j != ispList.end(); ++j) {
			delete j->second;
		}
		ispList.clear();
	}
	Isp::Ptr& getISP(const string& IP);
	bool isBadRange(const u_int32_t aKey);
	Isp::List& getIspList() {
		Lock l(ics);
		return ispList; 
	}

	FileListDetectorProfile::List& getFileListDetectors() {
		Lock l(fgcs);
		return fileListDetector;
	}
	
	FileListDetectorProfile addFileListDetector(const string& name, const string& cheatingdescription, 
		int rawToSend, const string& client) {
		Lock l(fgcs);
		fileListDetector.push_back(
			FileListDetectorProfile(
			lastFDProfile++, 
			name, 
			cheatingdescription,
			rawToSend 
			//Sulan start svn120
			, client
			//End
			)
		);
		return fileListDetector.back();
	}

	void addFileListDetector( const StringList& sl ) {
		Lock l(fgcs);
		fileListDetector.push_back(
			FileListDetectorProfile(
			lastFDProfile++, 
			sl[0], 
			sl[1], 
			0
			//Sulan start svn120
			, sl[3] 
			)
		);
	}

	bool getFileListDetector(int id, FileListDetectorProfile& fd) {
		Lock l(fgcs);
		for(FileListDetectorProfile::Iter i = fileListDetector.begin(); i != fileListDetector.end(); ++i) {
			if(i->getId() == id) {
				fd = *i;
				return true;
			}
		}
		return false;
	}

	void removeFileListDetector(int id) {
		Lock l(fgcs);
		for(FileListDetectorProfile::Iter i = fileListDetector.begin(); i != fileListDetector.end(); ++i) {
			if(i->getId() == id) {
				fileListDetector.erase(i);
				break;
			}
		}
	}

	void updateFileListDetector(const FileListDetectorProfile& fd) {
		Lock l(fgcs);
		for(FileListDetectorProfile::Iter i = fileListDetector.begin(); i != fileListDetector.end(); ++i) {
			if(i->getId() == fd.getId()) {
				*i = fd;
				break;
			}
		}
	}

	void loadClientProfiles();
	void loadFakeShares();
	void loadISPs();

	void saveClientProfiles();
	void saveFakeShares();
	void saveISPs();

	//Sulan start svn51
	GETSET(string, profileVersion, ProfileVersion);
	GETSET(string, profileMessage, ProfileMessage);
	GETSET(string, profileUrl, ProfileUrl);
	//End

	// pothead starts svn196 (sulan code)
	GETSET(string, myinfoProfileVersion, MyinfoProfileVersion);
	GETSET(string, myinfoProfileMessage, MyinfoProfileMessage);
	GETSET(string, myinfoProfileUrl, MyinfoProfileUrl);

	void saveMyinfoProfiles();
	void loadMyinfoProfiles();
	MyinfoProfile::List& getMyinfoProfiles() {
		Lock l(ipcs);
		return myinfoProfiles;
	}

	MyinfoProfile::List& getMyinfoProfiles(StringMap &paramList) {
		Lock l(ipcs);
		paramList = params;
		return myinfoProfiles;
	}
	
	MyinfoProfile addMyinfoProfile(
		const string& name, 
		const string& version, 
		const string& tag, 
		const string& extendedTag,
		const string& nick, 
		const string& shared, 
		const string& email,
		const string& status,
		const string& cheatingdescription, 
		int rawToSend,
		bool useExtraVersion, 
		const string& connection,
		const string& comment
		) 
	{
		Lock l(ipcs);
		myinfoProfiles.push_back(
			MyinfoProfile(
			lastMyinfoProfile++, 
			name, 
			version, 
			tag, 
			extendedTag, 
			nick, 
			shared, 
			email,
			status, 
			cheatingdescription,
			rawToSend, 
			useExtraVersion, 
			connection,
			comment
			)
		);
		return myinfoProfiles.back();
	}

	void addMyinfoProfile( const StringList& sl ) {
		Lock l(ipcs);
		myinfoProfiles.push_back(
			MyinfoProfile(
			lastMyinfoProfile++, 
			sl[0], 
			sl[1], 
			sl[2], 
			sl[3], 
			sl[4], 
			sl[5], 
			sl[6], 
			sl[7], 
			sl[8],
			Util::toInt(sl[9]), 
			Util::toBool(sl[10]), 
			sl[11], 
			sl[12]
			)
		);
		saveMyinfoProfiles();
	}

	bool getMyinfoProfile(int id, MyinfoProfile& ip) {
		Lock l(ipcs);
		for(MyinfoProfile::Iter i = myinfoProfiles.begin(); i != myinfoProfiles.end(); ++i) {
			if(i->getId() == id) {
				ip = *i;
				return true;
			}
		}
		return false;
	}

	void removeMyinfoProfile(int id) {
		Lock l(ipcs);
		for(MyinfoProfile::Iter i = myinfoProfiles.begin(); i != myinfoProfiles.end(); ++i) {
			if(i->getId() == id) {
				myinfoProfiles.erase(i);
				break;
			}
		}
	}

	void updateMyinfoProfile(const MyinfoProfile& ip) {
		Lock l(ipcs);
		for(MyinfoProfile::Iter i = myinfoProfiles.begin(); i != myinfoProfiles.end(); ++i) {
			if(i->getId() == ip.getId()) {
				*i = ip;
				break;
			}
		}
	}

	bool moveMyinfoProfile(int id, int pos/*, int position*/) {
		dcassert(pos == -1 || pos == 1);
		Lock l(ipcs);
		for(MyinfoProfile::Iter i = myinfoProfiles.begin(); i != myinfoProfiles.end(); ++i) {
			if(i->getId() == id) {
				swap(*i, *(i + pos));
				return true;
			}
		}
		return false;
	}

	// pothead ends
	// pothead starts svn207
	void saveRawProfiles();
	void loadRawProfiles();

	RawProfile::List& getRawProfiles() {
		Lock l(rpcs);
		return rawProfiles;
	}

	bool nameInUse(const string& aName){
		for(RawProfile::Iter i = rawProfiles.begin(); i != rawProfiles.end(); ++i) {
			if(Util::stricmp(aName, i->getName())==0)
				return true;
		}
		return false;
	}

	RawProfile addRawProfile( const StringList& sl ) {
		Lock l(rpcs);
		rawProfiles.push_back(
			RawProfile(
			lastRawProfile++, 
			sl[0],
			sl[1],
			sl[2],
			sl[3],
			sl[4],
			sl[5],
			sl[6],
			sl[7],
			sl[8], 
			sl[9],
			sl[10]
			)
		);
		saveRawProfiles();
		return rawProfiles.back();
		
	}

	bool getRawProfile(int id, RawProfile& ip) {
		Lock l(rpcs);
		for(RawProfile::Iter i = rawProfiles.begin(); i != rawProfiles.end(); ++i) {
			string test = Util::toString(i->getId());
			if(i->getId() == id) {
				ip = *i;
				return true;
			}
		}
		return false;
	}

	void removeRawProfile(int id) {
		Lock l(rpcs);
		for(RawProfile::Iter i = rawProfiles.begin(); i != rawProfiles.end(); ++i) {
			if(i->getId() == id) {
				rawProfiles.erase(i);
				break;
			}
		}
	}

	void updateRawProfile(const RawProfile& ip) {
		Lock l(rpcs);
		for(RawProfile::Iter i = rawProfiles.begin(); i != rawProfiles.end(); ++i) {
			if(i->getId() == ip.getId()) {
				*i = ip;
				break;
			}
		}
	}
	// pothead ends
	void setRawName(int num, const string& aString) {
		switch(num) {
			case 1:		 rawstring1 = aString;break;
			case 2:		 rawstring2 = aString;break;
			case 3:		 rawstring3 = aString;break;
			case 4:		 rawstring4 = aString;break;
			case 5:		 rawstring5 = aString;break;
			case 6:		 rawstring6 = aString;break;
			case 7:		 rawstring7 = aString;break;
			case 8:		 rawstring8 = aString;break;
			case 9:		 rawstring9 = aString;break;
			case 10:	 rawstring10= aString;break;
			default:	STRING(NO_ACTION);break;
		}
	}
	
private:
	ClientProfile::List clientProfiles;
	int lastProfile;
	int lastMyinfoProfile;
	int lastFDProfile;
	int lastRawProfile;
	FakeShares::List fakeShares;
	FileListDetectorProfile::List fileListDetector;
	StringMap params;

	Isp::List ispList;
	static Isp::Ptr unknown;

	CriticalSection ccs, fcs, ics, fgcs, ipcs, rpcs;

	friend class Singleton<ClientProfileManager>;
	
	ClientProfileManager() : lastProfile(0), lastFDProfile(0), lastMyinfoProfile(0), lastRawProfile(0) {
		rawstring1 = "Raw 1";
		rawstring2 = "Raw 2";
		rawstring3 = "Raw 3";
		rawstring4 = "Raw 4";
		rawstring5 = "Raw 5";
		rawstring6 = "Raw 6";
		rawstring7 = "Raw 7";
		rawstring8 = "Raw 8";
		rawstring9 = "Raw 9";
		rawstring10 = "Raw 10";
	}

	GETSET(string, rawstring1, Rawstring1);
	GETSET(string, rawstring2, Rawstring2);
	GETSET(string, rawstring3, Rawstring3);
	GETSET(string, rawstring4, Rawstring4);
	GETSET(string, rawstring5, Rawstring5);
	GETSET(string, rawstring6, Rawstring6);
	GETSET(string, rawstring7, Rawstring7);
	GETSET(string, rawstring8, Rawstring8);
	GETSET(string, rawstring9, Rawstring9);
	GETSET(string, rawstring10, Rawstring10);

	virtual ~ClientProfileManager() {
		clearISPList();
	}

	void loadClientProfiles(SimpleXML* aXml);
	void loadFakeShares(SimpleXML* aXml);
	void loadISPs(SimpleXML* aXml);	

	// pothead starts svn196 (sulan code) svn207
	MyinfoProfile::List myinfoProfiles;
	void loadMyinfoProfiles(SimpleXML* aXml);
	RawProfile::List rawProfiles;
	void loadRawProfiles(SimpleXML* aXml);
	// pothead ends
	string getRawName(int num) {
		switch(num) {
			case 1:		return rawstring1;
			case 2:		return rawstring2;
			case 3:		return rawstring3;
			case 4:		return rawstring4;
			case 5:		return rawstring5;
			case 6:		return rawstring6;
			case 7:		return rawstring7;
			case 8:		return rawstring8;
			case 9:		return rawstring9;
			case 10:	return rawstring10;
			default:	return "No action";
		}
	}
};

#define RAWSETTING(r) (ClientProfileManager::getInstance()->getRawName(r))
#endif // !defined(__CLIENT_PROFILE_MANAGER_H)
/**
 * @file
 * $Id: ClientProfileManager.h 331 2005-09-02 11:13:58Z sulan $
 */